<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>全返订单</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript">
$(function(){
	$('.search').bind("mouseenter", function (e) {
		$(this).addClass("hover");
	}).bind("mouseleave", function (e) {
		//$(this).removeClass("hover");
	});
	$('.close').bind("click", function (e) {
		$(this).parent().parent().removeClass("hover");
	});
	
	$('#stime,#p_stime,#s_stime').click(function () {
	var left = $("#Calendar").css("left");
	left = left.substring(0,left.length-2);
	left = left - 359;
	left = left+"px";
	var top = $("#Calendar").css("top");
	top = top.substring(0,top.length-2);
	top = top - 90;
	top = top+"px";
	$("#Calendar").css("left",left);
	$("#Calendar").css("top",top);
});
$('#etime,#p_etime,#s_etime').click(function () {
	var left = $("#Calendar").css("left");
	left = left.substring(0,left.length-2);
	left = left - 359;
	left = left+"px";
	var top = $("#Calendar").css("top");
	top = top.substring(0,top.length-2);
	top = top - 90;
	top = top+"px";
	$("#Calendar").css("left",left);
	$("#Calendar").css("top",top);
});

$(".a-opear").live('click',function(){
    
    var data = $(this).attr('data-param');
    eval("data = "+data);
    var type = $(this).attr('data-type');
    if(!data.order_id)
    {
        error('error','对不起，请选择订单后操作！');
        return false;
    }
    
    window.parent.ajax_form("quanfan_order", "操作售后申请", '<{$config.weburl}>/admin/module.php?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&act=opear&type='+type+'&orderId='+data.order_id, 800);
    return false;
    
});
});

//显示总销售额
function showSellAmount(cond){
	$.post('<{$config.weburl}>/admin/module.php?m=huopin&s=order.php',{"act":"getSellAmountByCond","cond":''+cond+''},function(s){
		window.parent.html_form('sellAmount','总销售额',s,800,300);
	});
}
</script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>全返订单</h3>
                <ul>
                    <li <{if $smarty.get.operation=='' and $smarty.get.type===''}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>"><span>管理</span></a></li>
                    
                    <li <{if $smarty.get.type=='1'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=1"><span>未支付</span></a></li>
                    <li <{if $smarty.get.type=='2'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=2"><span>已支付</span></a></li>
                    <li <{if $smarty.get.type=='0'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=0"><span>已取消</span></a></li>
                    
                    <{if $smarty.get.operation=='edit'}>
                    <li class="current"><a href="#"><span>操作</span></a></li>
                    <{/if}>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <{if $smarty.get.operation=='edit' }>
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">订单详情</th>
                    </tr>
                </thead>
                <tbody>
                <tr class="tr">
                    <td width="50">订单状态</td>
                    <td width="50"><b class="org"><{assign var=val value=$de.status}><{$statu_list.$val}></b></td>
                
                    <td width="50">订单编号</td>
                    <td width="50"><{$de.order_id}></td>
                    
                    <td width="50">下单时间</td>
                    <td width="100"><{$de.create_time|date_format:"%Y-%m-%d %H:%M:%S"}></td>
                </tr>
                <tr>
                    <{if $de.pay_time>0}>
                    <td width="50">付款时间</td>
                    <td width="100"><{$de.pay_time|date_format:"%Y-%m-%d %H:%M:%S"}></td>
                    
                    <td width="50">支付方式</td>
            		<td><{$de.payment_name}></td>
                    <{/if}>
                    
                    <td width="50">订单金额</td>
                    <td width="100"><{$config.money}><b class="red"><{$de.total_price}></b></td>
                    
                    <td width="50">备注</td>
                    <td width="100"><{$de.admin_remark}></td>
                </tr>
                </tbody>
            </table>
            <table class="table">    
                <thead>
                    <tr>
                        <th class="partition" colspan="99">订单商品信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                    	<td></td>
                        <td>产品名称</td>
                        <td width="150">单价（元）</td>
                        <td width="150">数量</td>
                        <td width="300">总价（元）</td>
                    </tr>
                    <{foreach item=list from=$productList}>
                    <tr>
                        <td width="90"><a target="_blank" href="<{$list.pic}>"><img width="80" src="<{$list.pic}>"></a></td>
                        <td><{$list.product_name}></td>
                        <td>&nbsp;<{$list.price|number_format:2}></td>
                        <td>&nbsp;<{$list.num}></td>
                        <td>&nbsp;<{$list.price*$list.num|number_format:2}></td>
                    </tr>
                    <{/foreach}>
                </tbody>
            </table>
            <{if $de.status!=0}>
            <form name="form1" id="form1" method="post">
            <input name="m" type="hidden" value="<{$smarty.get.m}>">
            <input name="s" type="hidden" value="<{$smarty.get.s}>">
            <input name="id" type="hidden" id="id" value="<{$de.id}>">
            <table class="table">
            	<thead>
                    <tr>
                        <th class="partition" colspan="99">取消订单</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100" valign="top"><div class="mt10">取消缘由</div></td>
                    <td>
                    <ul class="cancel">
                        <li>
                            <input type="radio" value="无法备齐货物" id="d1" name="admin_remark" checked="">
                            <label for="d1">无法备齐货物</label>
                        </li>
                        <li>
                            <input type="radio" value="不是有效的订单" id="d2" name="admin_remark">
                            <label for="d2">不是有效的订单</label>
                        </li>
                        <li>
                            <input type="radio" value="买家主动要求" id="d3" name="admin_remark">
                            <label for="d3">买家主动要求</label>
                        </li>
                        <li>
                            <input type="radio" value="其他原因" id="d4" flag="other_reason" name="admin_remark">
                            <label for="d4">其他原因</label>
                        </li>
                        <li style="display:none; height:48px;" id="other_reason">
                        	<textarea class="w300" rows="2" name="other_reason"></textarea>
                        </li>
                    </ul>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" onclick="return confirm('您确实要取消该订单吗');" type="submit" value="取消订单">
                    <input name="act" type="hidden" id="action" value="cancel">
                    </td>
                </tr>
                </tbody>
			</table>
            </form>
            <script type="text/javascript">
			$(function(){
				$("input[name='admin_remark']").click(function(){
					if ($(this).attr('flag') == 'other_reason')
					{
						$('#other_reason').show();
					}
					else
					{
						$('#other_reason').hide();
					}
				});
			});
			</script> 
            <{/if}>
        <{else}>
        <table class="select_table">
        <tr>    
            <td>
            	<div class="select_box">
                <form action="" method="get">
                    <input type="hidden" name="m" value="<{$smarty.get.m}>">
                    <input type="hidden" name="s" value="order.php">
                    <input type="hidden" name="status" value="<{$smarty.get.status}>">
										<select name="stock_shop" id="stock_shop" style="float:left;">
                <option value="" <{if $general_shop!=0}>disabled<{/if}>>全部</option>
                <{foreach item=list from=$stock_shops}>
                <option value="<{$list.id}>" <{if $smarty.get.stock_shop==$list.id}>selected<{/if}> <{if $general_shop!=0&&$general_shop!=$list.id}>disabled<{/if}>><{$list.title}></option>
                
                <{/foreach}>
                </select>
                    <input placeholder="请输入订单编号..." type="text" name="code" class="txt w250" value="<{$smarty.get.code}>" />
                    <input type="submit" value="搜索" />
                </form>
                </div>
                <div class="search">
                	<a class="a-search" href="#">高级搜索</a>
                	<div class="div-search">
                        <div class="close"></div>
                        <div class="line"></div>
                        <div class="search-con clearfix">
                        <form action="" method="get">
                        <input type="hidden" name="m" value="<{$smarty.get.m}>">
                        <input type="hidden" name="s" value="order.php">
                        <input type="hidden" name="type" value="<{$smarty.get.type}>">
                        <dl>
                            <dt>订单编号</dt>
                            <dd><input type="text" class="w250" name="code" value="<{$smarty.get.code}>" /></dd>
                        </dl>
                        <dl>
                            <dt>支付状态</dt>
                            <dd>
                            <select name="order_pay_status" class="w250">
                            <option value="">请选择</option>
                            <option <{if $smarty.get.order_pay_status==2}>selected="selected"<{/if}> value="2">已支付</option>
                            <option <{if $smarty.get.order_pay_status==1}>selected="selected"<{/if}> value="1">未支付</option>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>支付方式</dt>
                            <dd>
                            <select name="pay" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$pay}>
                            <option <{if $smarty.get.pay==$list.payment_id}>selected="selected"<{/if}> value="<{$list.payment_id}>"><{$list.payment_name}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>                      
                        <dl>
                            <dt>订单总额</dt>
                            <dd>
                            <input type="text" class="w118" name="minp" value="<{$smarty.get.minp}>" />
                            -
							<input type="text" class="w118" name="maxp" value="<{$smarty.get.maxp}>" />
                            </dd>
                        </dl>
                        <dl>
                            <dt>下单时间</dt>
                            <dd>
                            <script language="javascript">
            var cdr = new Calendar("cdr");
            document.write(cdr);
            cdr.showMoreDay = true;
        </script>
                            <input onFocus="cdr.show(this);" class="w118" type="text" name="stime" id="stime" value="<{$smarty.get.stime}>"">
                            -
							<input onFocus="cdr.show(this);" class="w118" type="text" name="etime" id="etime" value="<{$smarty.get.etime|default:$smarty.now+86399|date_format:'%Y-%m-%d'}>"">
                            </dd>
                        </dl>                        
                        <dl>
                            <dt>支付时间</dt>
                            <dd>
                            <script language="javascript">
            var pcdr = new Calendar("pcdr");
            document.write(pcdr);
            pcdr.showMoreDay = true;
        </script>
                            <input onFocus="pcdr.show(this);" class="w118" type="text" name="p_stime" id="p_stime" value="<{$smarty.get.p_stime}>"">
                            -
                            <input onFocus="pcdr.show(this);" class="w118" type="text" name="p_etime" id="p_etime" value="<{$smarty.get.p_etime|default:$smarty.now+86399|date_format:'%Y-%m-%d'}>"">
                            </dd>
                        </dl>                        
                        <dl>
                            <dt>买家名称</dt>
                            <dd><input type="text" class="w250" name="user" value="<{$smarty.get.user}>" /></dd>
                        </dl>
                        <dl>
                            <dt>会员ID</dt>
                            <dd><input type="text" class="w250" name="userid" value="<{$smarty.get.userid}>" /></dd>
                        </dl>
                    	<input type="submit" value="搜索" />
                        </form>
                        </div>
                    </div>
                </div>
                <a class="refresh" href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&status=<{$smarty.get.status}>"></a>
                <div style="float:right">
   	 				<a href="javascript:;" onclick="showSellAmount('<{$amountCond}>');">显示总销售额</a>&nbsp;&nbsp;&nbsp;&nbsp;
            	</div>                
	           </td>
	        </tr>
	    </table>
        <table class="table">
        	<thead>
                <tr>
                    <th class="partition" colspan="99">全返订单</th>
                </tr>
            </thead>
            <tbody>
                <tr class="header">
                    <th width="100">订单编号</th>
                    <th width="100">会员</th>
                    <!-- <th width="100">全返名称</th> -->
                    <th width="100">订单总价</th>
                    <!-- <th width="100">全返状态</th> -->
                    <th width="100">支付状态</th>
                    <th width="100">支付方式</th>
                    <th width="100">平台/系统</th>
                    <th width="150">下单时间</th>
                    <th width="50">操作</th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td style="position:relative;padding-left:32px;"><{if $list.stock_shop}><i style="background:url(/image/admin/<{$list.stock_shop}>.png);display: block;height: 32px;left: 0;top:50%; margin-top:-16px;position: absolute;width: 32px;"></i><{/if}><{$list.order_id}></td>
                    <td>
                    	ID:<{$list.member_id}>
                    <br/>
                    	名称:<{if $list.username}><{$list.username}><{else}><{$list.nick_name}>(昵称)<{/if}>
                    </td>
                   <!--  <td><{$list.hp_title}></td> -->
                    <td><{$list.total_price}></td>
                    <!-- <td><{$list.hpStatusStr}></td> -->
                    <td>
                    	<{if $list.payment_status==1 }>
                    	未支付
                    	<{else if $list.payment_status==2 }>
                    	(<{$list.pay_time}>)
                    	<br/>已支付
                    	<{/if}>
                    </td>
                    <td><{$list.payment_name}></td>
                    <td><{$list.client_platform_str}>/<{$list.client_system_str}></td>
                    <td><{$list.order_time|date_format:"%Y-%m-%d %H:%M:%S"}></td>
                    <td>
                    <a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=edit&editid=<{$list.id}>"><{$editimg}></a>
                    <{if $list.payment_status==1 and $list.status==1 }>
                    &nbsp;&nbsp;<a class="a-opear" data-type="pay" data-param="{'order_id':'<{$list.order_id}>'}" href="javascript:;">付款</a>
                    <!-- <a class="a-opear" data-type="cancel" data-param="{'order_id':'<{$list.order_id}>'}" href="javascript:;">取消</a> -->
                    <{/if}>
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="99">
                    	<div class="fl">每页最多显示： <{$de.perPageRows}>条</div>
                    	<div class="page"><{$de.page}></div>
                    	<div class="fr">共有<{$de.count}>条记录</div>
                    </td>
                </tr>
            </tfoot>
        </table>
        <{/if}>
    </div>
</body>
</html>